home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / asm / adisv1_3.lha / src / globals.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-24  |  5.9 KB  |  271 lines

  1. /*
  2.  * Change history
  3.  * $Log:    globals.c,v $
  4.  * Revision 3.0  93/09/24  17:54:00  Martin_Apel
  5.  * New feature: Added extra 68040 FPU opcodes
  6.  * 
  7.  * Revision 2.1  93/07/18  22:55:57  Martin_Apel
  8.  * *** empty log message ***
  9.  * 
  10.  * Revision 2.0  93/07/01  11:54:00  Martin_Apel
  11.  * *** empty log message ***
  12.  * 
  13.  * Revision 1.15  93/07/01  11:39:52  Martin_Apel
  14.  * Minor mod.: Prepared for tabs instead of spaces.
  15.  * Minor mod.: Added 68030 opcodes to disable list
  16.  * 
  17.  * Revision 1.14  93/06/19  12:08:38  Martin_Apel
  18.  * Major mod.: Added full 68030/040 support
  19.  * 
  20.  * Revision 1.13  93/06/16  20:28:04  Martin_Apel
  21.  * Minor mod.: Removed #ifdef FPU_VERSION and #ifdef MACHINE68020
  22.  * Minor mod.: Added variables for 68030 / 040 support
  23.  * 
  24.  * Revision 1.12  93/06/06  13:46:34  Martin_Apel
  25.  * Minor mod.: Replaced first_pass and read_symbols by pass1, pass2, pass3
  26.  * 
  27.  * Revision 1.11  93/06/06  00:11:41  Martin_Apel
  28.  * Major mod.: Added support for library/device disassembly (option -dl)
  29.  * 
  30.  * Revision 1.10  93/06/04  11:50:40  Martin_Apel
  31.  * New feature: Added -ln option for generation of ascending label numbers
  32.  * 
  33.  * Revision 1.9  93/06/03  20:27:16  Martin_Apel
  34.  * New feature: Added -a switch to generate comments for file offsets
  35.  * 
  36.  * Revision 1.8  93/06/03  18:31:10  Martin_Apel
  37.  * Minor mod.: Added hunk_end array
  38.  * Minor mod.: Remove temporary files upon exit (even with CTRL-C)
  39.  * 
  40.  */
  41.  
  42. #include <exec/types.h>
  43. #include "defs.h"
  44.  
  45. static char rcsid [] = "$Id: globals.c,v 3.0 93/09/24 17:54:00 Martin_Apel Exp $";
  46.  
  47. unsigned short *code;
  48. char opcode [20];
  49. char src [200];
  50. char dest [200];
  51. char instruction [400];
  52.  
  53. unsigned long current_address;
  54. unsigned long first_address;
  55. unsigned long last_address;
  56. unsigned long total_size;
  57. unsigned long current_hunk;
  58. unsigned char *flags;
  59. long *hunk_start = NULL,
  60.      *hunk_end = NULL,
  61.      *hunk_offset = NULL;
  62. long f_offset; 
  63. short tabsize;
  64.  
  65. BOOL end_instr;
  66.  
  67. FILE *in = 0,
  68.      *out = 0,
  69.      *tmp_f = NULL;
  70. char *in_buf = 0,
  71.      *out_buf = 0;
  72. char *input_filename = 0;
  73. BOOL pass1,
  74.      pass2,
  75.      pass3;
  76. BOOL detected_illegal;
  77. BOOL warning_printed = FALSE;
  78. BOOL single_file = TRUE;
  79. int num_code_hunks = 0;
  80. int num_data_hunks = 0;
  81. int num_bss_hunks = 0;
  82. int num_hunks;
  83. BOOL ROMTagFound = FALSE;
  84. /* pointer to format_line function: */
  85. void (*format_line) (BOOL, BOOL) = format_line_spaces;
  86.  
  87. /* Variables for options */
  88. char output_filename [200];        /* -o */
  89. int buf_size = DEF_BUF_SIZE;       /* -b */
  90.  
  91. /* Try to resolve addressing used by many compilers in small mode. */
  92. /* (Addressing relative to A4) */
  93. BOOL try_small = TRUE;             /* -s */
  94. long a4_offset = -1;
  95.                                    
  96. BOOL print_illegal_instr_address = FALSE;         /* -i */
  97. BOOL mc68881 = FALSE,              /* -c8 */
  98.      mc68020 = FALSE,              /* -c2 */
  99.      ext_68020_modes = FALSE,      /* -ce */
  100.      mc68030 = FALSE,              /* -c3 */
  101.      mc68040 = FALSE;              /* -c4 */
  102. BOOL disasm_quick = FALSE;         /* -q */
  103. BOOL user_wants_single_file = FALSE,    /* -fs */
  104.      user_wants_separate_files = FALSE; /* -fm */
  105. BOOL add_file_offset = FALSE;           /* -a  */
  106. BOOL ascending_label_numbers = FALSE;   /* -ln */
  107. BOOL use_tabs = FALSE;                  /* -t */
  108. #ifdef AMIGA
  109. BOOL disasm_as_lib = FALSE;             /* -dl */
  110. #endif
  111.  
  112. #ifdef DEBUG
  113. BOOL verbose = TRUE;               /* -v */
  114. #else
  115. BOOL verbose = FALSE;
  116. #endif
  117.  
  118. char *reg_names [] =
  119.   {
  120.   "D0",
  121.   "D1",
  122.   "D2",
  123.   "D3",
  124.   "D4",
  125.   "D5",
  126.   "D6",
  127.   "D7",
  128.   "A0",
  129.   "A1",
  130.   "A2",
  131.   "A3",
  132.   "A4",
  133.   "A5",
  134.   "A6",
  135.   "SP",
  136.   "PC",       /* Start at offset 17 */
  137.   "FP0",
  138.   "FP1",
  139.   "FP2",
  140.   "FP3",
  141.   "FP4",
  142.   "FP5",
  143.   "FP6",
  144.   "FP7"
  145.   };
  146.  
  147. char *conditions [] =
  148.   {
  149.   "T",
  150.   "F",
  151.   "HI",
  152.   "LS",
  153.   "CC",
  154.   "CS",
  155.   "NE",
  156.   "EQ",
  157.   "VC",
  158.   "VS",
  159.   "PL",
  160.   "MI",
  161.   "GE",
  162.   "LT",
  163.   "GT",
  164.   "LE"
  165.   };
  166.  
  167. char *special_regs [] =
  168.   {
  169.   "SR",        /* 0 */
  170.   "CCR",       /* 1 */
  171.   "USP",       /* 2 */
  172.   "SFC",       /* 3 */
  173.   "DFC",       /* 4 */
  174.   "CACR",      /* 5 */
  175.   "VBR",       /* 6 */
  176.   "CAAR",      /* 7 */
  177.   "MSP",       /* 8 */
  178.   "ISP",       /* 9 */
  179.   "TC",        /* 10 */
  180.   "ITT0",      /* 11 */
  181.   "ITT1",      /* 12 */
  182.   "DTT0",      /* 13 */
  183.   "DTT1",      /* 14 */
  184.   "MMUSR",     /* 15 */
  185.   "URP",       /* 16 */
  186.   "SRP",       /* 17 */
  187.   "TT0",       /* 18 */
  188.   "TT1",       /* 19 */
  189.   "CRP"        /* 20 */
  190.   };
  191.  
  192. /**********************************************************************/
  193. /*      When the program is compiled for use on a 68020 system,       */
  194. /*        68020 instructions disassembly can be switched off          */
  195. /*                     via a command line switch.                     */
  196. /*      Then those following instructions are marked as illegal       */
  197. /**********************************************************************/
  198.  
  199. short mc68020_disabled [] =
  200.   {
  201.     3, /* CHK2, CMP2 */
  202.    11, /* CHK2, CMP2 */
  203.    19, /* CHK2, CMP2 */
  204.    27, /* CALLM */
  205.    43, /* CAS */
  206.    51, /* CAS */
  207.    56, /* MOVES */
  208.    57, /* MOVES */
  209.    58, /* MOVES */
  210.    59, /* CAS */
  211.   260, /* CHK.L */
  212.   268, /* CHK.L */
  213.   276, /* CHK.L */
  214.   284, /* CHK.L */
  215.   292, /* CHK.L */
  216.   300, /* CHK.L */
  217.   304, /* MUL .L */
  218.   305, /* DIV .L */
  219.   308, /* CHK.L */
  220.   316, /* CHK.L */
  221.   931, /* BFTST */
  222.   935, /* BFEXTU */
  223.   939, /* BFCHG */
  224.   943, /* BFEXTS */
  225.   947, /* BFCLR */
  226.   951, /* BFFFO */
  227.   955, /* BFSET */
  228.   959, /* BFINS */
  229.  1027, /* RTM */
  230.  1028, /* UNPK */
  231.  1032, /* PACK */
  232.  1040, /* CAS2 */
  233.  1041, /* CAS2 */
  234.  1042, /* CAS2 */
  235.  1045, /* TRAPcc */
  236.  1049, /* BKPT */
  237.  1051, /* EXTB.L */
  238.     0
  239.   };
  240.  
  241. short mc68881_disabled [] =
  242.   {
  243.   968, /* General fpu opcode */
  244.   969, /* FScc */
  245.   970, /* FBcc */
  246.   971, /* FBcc */
  247.   972, /* FSAVE */
  248.   973, /* FRESTORE */
  249.  1047, /* FDBcc */
  250.  1048, /* FTRAPcc */
  251.     0
  252.   };
  253.  
  254. short mc68030_disabled [] =
  255.   {
  256.   960, /* MMU instructions */
  257.   0
  258.   };
  259.  
  260. short mc68040_disabled [] =
  261.   {
  262.   976, /* CPUSH, CINV */
  263.   977, /* CPUSH, CINV */
  264.   978, /* CPUSH, CINV */
  265.   979, /* CPUSH, CINV */
  266.   980, /* PFLUSH */
  267.   981, /* PTEST */
  268.   984, /* MOVE16 */
  269.     0
  270.   };
  271.